$(document).ready(function () {
});

function loadDate() {
    var list = [];

    var train = [];
    $("select[name='train']").each(function (index, a) {
        train.push($(this).val())
        j = index
    });
    var sportType = [];
    $("input[name='sportType']").each(function (index, a) {
        sportType.push($(this).val())
    });
    var strength = [];
    $("input[name='strength']").each(function (index, a) {
        strength.push($(this).val())
    });
    var sportTime = [];
    $("input[name='sportTime']").each(function (index, a) {
        sportTime.push($(this).val())
    });
    for (i = 0; i < train.length; i++) {
        var obj = {
            "train": train[i],
            "sportType": sportType[i],
            "strength": strength[i],
            "sportTime": sportTime[i]
        }
        list.push(obj)
    }
    var url = '/ui/rehabilitation/prescription';
    $.ajax({
        url: url,
        type: 'POST',
        data: JSON.stringify({
            sportWay: {
                "area": $('#area').val(),
                "office": $('#office').val(),
                "sportTime": $('#sportTime').val(),
                "runTime": $('#runTime').val(),
                "sportNum": $('#sportNum').val(),
                "sportAttention": $('#sportAttention').val(),
                "doctor": $('#doctor').val(),
                "patientId": $('#patient').val()
            },
            sportTrainList: list
        }),
        success: function (data) {
            var result = data.responseCode;
            if (result == "0000") {
                alert("保存成功")
                location.reload()
            } else {
                alert("保存失败")
            }
        },
        error: function (jqXHR, textStatus, errorThrown) {
            console.log(errorThrown);
        },
        contentType: "application/json;charset=utf-8",
        processData: false

    });
}
